
/**
 * 对控制器进行加密
 */
module.exports = (filterArr = []) => {
    return async (ctx, next)=>{
        if(!filterArr.includes(ctx.__req.method)){
            let data = ctx.request.body;
            data = ctx.fun.decrypt(data);
            if(!data){
                ctx._throw(404,'Commit data error!');
            }
            try {
                data = JSON.parse(data);
                ctx.request.body = data;
            } catch (e) {
                ctx._throw(404,'Commit data error2!');
            }
            
        }
        await next();//放行
        if(!filterArr.includes(ctx.__req.method)){
            let data = ctx.body;
            data = ctx.fun.encrypt(data);
            ctx.body = data;
        }
    };
};